package com.luocc.ccdemo.db

import com.luocc.ccdemo.entity.Result
import com.luocc.ccdemo.entity.User
import com.luocc.ccdemo.utils.Api
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class UserRepository {
    suspend fun login(user: User): Result<String> {
        return withContext(Dispatchers.IO) {
            Api.login(user)
        }
    }

    suspend fun logout(): Result<Boolean> {
        return withContext(Dispatchers.IO) {
            Api.logout()
        }
    }

    suspend fun register(username: String, password: String, rePassword: String): Result<Boolean> {
        return withContext(Dispatchers.IO) {
            Api.register(username, password, rePassword)
        }
    }
}